<%--
  Created by IntelliJ IDEA.
  User: 18042986105
  Date: 2021/6/12
  Time: 19:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="toolbarDemo.jsp"%>
<html>
<head>
    <title>Title</title>
</head>
<style type="text/css">
    tr{
        padding:0;
        margin:0;
        line-height:80px;

    }
    .layui-table-cell{
        height:100px;
        width:133px;
        display: flex;
        white-space: nowrap;
        line-height:25px;
    }
    .layui-table-cell #image{
        display: block;
        height:100px;
        width:133px;

    }
</style>
<body>
<table class="layui-hide"  id="test"  lay-filter="test" style="table-layout: fixed;"></table>
<script type="text/html" id="user-edit-bar">
    <a class="layui-btn layui-btn-xs" lay-event="edit-user">编辑</a>
</script>
<script src="../../layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['table','layer','form','laydate'], function(){
        var table = layui.table;
        var layer = layui.layer;
        var $ = layui.$;
        var form = layui.form;
        var laydate=layui.laydate;
        table.render({
            elem: '#test'
            ,url:'/normal/allfk'
            ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            ,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                ,limit:3
                ,limits:[2,3,5]
                ,groups: 3 //只显示 1 个连续页码

            }
            ,cols: [[
                {type:'checkbox'}
                ,{field:'id',  title: 'ID'}
                ,{field:'uname',  title: '用户'}
                ,{field:'ggmessage', title: '信息'}
                ,{field:'imgss', title: '图片',templet:function(data){
                        return data.imgss!=null? '<img id="image" src="'+data.imgss+'"/>':'';}}
                ,{field:'time',title:'时间'}
                ,{field:'types',title:'类型',templet:function(data){
                    return data.types==="st"?"食堂":(data.types==="ss"?"宿舍":(data.type==="jx"?"教学楼":"其它"));
                    }
            }

            ]]

        });
        //头工具栏事件
        table.on('toolbar(test)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){

                case 'delete':
                    var data = table.checkStatus('test').data;
                    if (data.length > 0) {
                        layer.confirm('确定删除吗骚年', function (index) {
                            var param = "";
                            $.each(data, function (i, obj) {
                                param += "&ids=" + obj.id
                            });
                            $.ajax({
                                url: '/normal/del',
                                data: param,
                                method: 'post',
                                success: function (result) {
                                    if (result.status) {
                                        table.reload('test', {});
                                    } else {
                                        alert(result.message)
                                    }
                                    layer.close(index);
                                }
                            })
                        });
                    }
                    break;

            }
        });


        // 监听提交
        form.on('submit(user-search)',function(data){
            table.reload('test',{
                page:{
                    curr:1
                },
                where :data.field
            });
            return false;
        })
        //结尾
        //结尾部分
    });
</script>

</body>
</html>

